home *** CD-ROM | disk | FTP | other *** search
- /* SCSIFindDevicesMain.c */
- /*
- * SCSIFindDevicesMain.c
- * Copyright © 1992-94 Apple Computer Inc. All Rights Reserved.
- */
- /*
- * This sample shows how to locate all attached SCSI devices.
- */
- #include <Folders.h>
- #include <Errors.h>
- #include <stdio.h>
- #ifdef THINK_C
- #include <console.h>
- #endif
- #include "SCSIFindDevices.h"
-
- SCSIFindDevicesRec gSCSIFindDevicesRec;
-
- void
- main(
- #ifdef THINK_C
- int argc,
- char **argv
- #endif
- )
- {
- OSErr status;
- int devicesFound;
-
- #ifdef THINK_C
- argc = ccommand(&argv);
- #endif
- /*
- * Initialize the Find "global" area. If deviceID.bus is 0xFF, the
- * find subroutine will initialize and return the first device.
- * Set the maxLUN field to zero to prevent multiple LUN recognition
- * or set it to seven to enable all LUNs.
- */
- gSCSIFindDevicesRec.deviceID.bus = 0xFF;
- gSCSIFindDevicesRec.maxLUN = 7;
- devicesFound = 0;
- while ((status = SCSIFindNextDevice(&gSCSIFindDevicesRec)) == noErr) {
- ++devicesFound;
- if (gSCSIFindDevicesRec.isAsyncSCSIPresent) {
- printf("%d.%d.%d \"%.8s\" \"%.16s\"\n",
- (int) gSCSIFindDevicesRec.deviceID.bus,
- (int) gSCSIFindDevicesRec.deviceID.targetID,
- (int) gSCSIFindDevicesRec.deviceID.LUN,
- gSCSIFindDevicesRec.inquiry.vendor,
- gSCSIFindDevicesRec.inquiry.product
- );
- }
- else {
- printf("%d.%d \"%.8s\" \"%.16s\"\n",
- (int) gSCSIFindDevicesRec.deviceID.targetID,
- (int) gSCSIFindDevicesRec.deviceID.LUN,
- gSCSIFindDevicesRec.inquiry.vendor,
- gSCSIFindDevicesRec.inquiry.product
- );
- }
- }
- if (status == eofErr)
- printf("Normal completion, %d devices found\n", devicesFound);
- else {
- printf("Failure: system error %d after finding %d devices\n",
- (int) status,
- devicesFound
- );
- }
- if (gSCSIFindDevicesRec.isAsyncSCSIPresent)
- printf("Using asynchronous SCSI Manager\n");
- else {
- printf("Using original SCSI Manager only\n");
- }
- }
-
-